package org.smr.ministore.service.impl;

import java.util.List;

import org.blade.service.base.AbstractService;
import org.blade.utils.Pager;

import org.smr.ministore.dao.UserRoleMapper;
import org.smr.ministore.entities.UserRole;
import org.smr.ministore.service.UserRoleService;

import org.springframework.beans.factory.annotation.Autowired;


import org.springframework.stereotype.Service;

@Service("UserRoleService")
public class UserRoleServiceImpl extends AbstractService implements UserRoleService {

	@Autowired
	private UserRoleMapper mapper;
	
	public int save(UserRole entity) {
		this.saveAttatch(entity);
		return mapper.insert(entity);
	}

	public int updateById(UserRole id) {
		this.modifyAttach(id);
		return mapper.updateById(id);
	}

	public UserRole queryById(Long id) {
		return mapper.selectById(id);
	}

	public int deleteById(Long id) {
		return mapper.deleteById(id);
	}

	public Pager<UserRole> paginate( UserRole entity, Long pageSize, Long pageNum) {

		Pager<UserRole> pager = new Pager( pageSize, pageNum );
		List list  = mapper.pagination(entity, pager);
		pager.setEntities(list);
		return pager;
    }
	
	public int batchSave(List<UserRole> entities) {
		return mapper.batchInsert(entities);
	}

}
